<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use DB;


class BankShop extends Authenticatable
{
    use Notifiable;
	protected $table = 'bank_show';

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
         'remember_token',
    ];

    // 获取可用的店铺名称
	public static function getAllBankShopId(){
		$bankShopArr = DB::table('bank_show')
			->where('state',1)
			->select('id','shopName')
			->get()
			->toArray();
		if(!$bankShopArr){
			return array();
		}
		return $bankShopArr;
	}
	// 获取指定网点的id和名称
	public static function getTheOneBankShopId($id){
		$bankShopArr = DB::table('bank_show')
			->where('state',1)
			->where('id',$id)
			->select('id','shopName')
			->get()
			->toArray();
		if(!$bankShopArr){
			return array();
		}
		return $bankShopArr;
	}

	// 根据id获取网点名称
	public static function getNameById($id){
		$name = '';
		$nameArr = BankShop::where('id',$id)->pluck('shopName');
		if($nameArr){
			$name = $nameArr[0];
		}
		return $name;
	}

	// 根据id获取手机号
	public static function getPhoneById($id){
		$phone = '';
		$phoneArr = BankShop::where('id',$id)->pluck('phone')->toArray();
		if($phoneArr){
			$phone = $phoneArr[0];
		}
		return $phone;
	}

	// 根据手机号获取id
	public static function getIdByPhone($phone){
		$id = '';
		$idArr = BankShop::where('phone',$phone)->pluck('id')->toArray();
		if($idArr){
			$id = $idArr[0];
		}
		return $id;
	}

	// 获取网点下的设备
	public static function getShopEquipment($aid){
		$data = DB::table('bank_show')
			->leftjoin('bankshow_equipment', 'bank_show.id', '=', 'bankshow_equipment.bank_show_id')
			->where('bank_show.id',$aid)
			->select('bankshow_equipment.*')
			->get()
			->toArray();
		if(!$data){
			return array();
		}
		return $data;
	}

	// 获取网点下所有订单
	public static function getShopOrderS($aid){
		$data = DB::table('bank_show')
			->leftjoin('order', 'bank_show.id', '=', 'order.bank_id')
			->where('bank_show.id',$aid)
			->select('order.*')
			->get()
			->toArray();
		if(!$data){
			return array();
		}
		return $data;
	}




}
